/**
 * Iniciação Científica - SAE-CNPQ - 2013/2013
 * autor: Agnaldo A Esmael
 * Orientadores: Prof. Dr Ricardo Torres e Dr. Jefersson A Santos
 */
package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import control.EventosGUI;

/**
 * @author agnaldo
 *
 */
public class MenuBarGeneral extends JMenuBar implements ActionListener{

	//atributos da classe
	private JMenu menuFile, menuEdit, menuSettings, menuHelp;
	private JMenuItem itNew, itOpenFile, itSalveFile, itExit, itSalveClassificator;
	EventosGUI trataEventos;
	
	public MenuBarGeneral( EventosGUI tEvt) {
		
		trataEventos = tEvt;
		
		//Menu File
		menuFile = new JMenu("File");
		
		itNew = new JMenuItem("New");
		itOpenFile = new JMenuItem("Open");
		itOpenFile.addActionListener(this);
		itSalveFile = new JMenuItem("Salve image");
		itSalveClassificator = new JMenuItem("Salve Classificator");
		itExit = new JMenuItem("Exit");
		
		itNew.addActionListener(this);
		itExit.addActionListener(this);
		
		menuFile.add(itNew);
		menuFile.add(itOpenFile);
		menuFile.add(itSalveFile);
		menuFile.add(itSalveClassificator);
		menuFile.add(itExit);
	
		this.add(menuFile);
		
		//Menu Edit
		menuEdit = new JMenu("Edit");
		this.add(menuEdit);
		
		//Menu Settings
		menuSettings = new JMenu("Settings");
		this.add(menuSettings);
		
		//Menu Help
		menuHelp = new JMenu("Help");
		this.add(menuHelp);
				
		
	}

	@Override
	public void actionPerformed(ActionEvent evento) {
		
		if (evento.getSource().equals((Object)itExit)){
			trataEventos.exitProgramm();	
		}
		else if (evento.getSource().equals(itOpenFile)){
			trataEventos.openImage();
		}
		else if (evento.getSource().equals(itNew)) {
			trataEventos.cleanData();
		}
		
	}//fim actionPerformed

}//fim MenuBarGeneral
